package org.javabasics.collection;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by LUOLIANG on 2016/8/29.
 * List复习测试
 */
public class MyList {
    public static void test() {
        List persons = new ArrayList();

        persons.add("张三");
        persons.add("李四");
        persons.add("王麻子");
        persons.add("马云");

        System.out.println("元素添加完毕-->" + persons);

        //插入新字符串
        persons.add(1, "马化腾");

        System.out.println("元素插入后-->" + persons);

        //删除第三个元素
        persons.remove(2);

        System.out.println("元素删除后-->" + persons);

        //输出元素位置
        System.out.println(persons.indexOf(new String("马化腾")));

    }

    public static void main(String[] args) {
        test();
    }
}
